package com.e3.basdoc.bank.model;

import com.e3.basdoc.region.model.RegionModel;
import com.e3.template.model.TGFTreeModel;

public class BankModel extends TGFTreeModel implements BankFields{
	private static final long serialVersionUID = 6196109721917322061L;
	
	private String code;
	
	private String name;
	
	private String shortName;
	
	private Long regionId;
	
	private RegionModel regionModel; 
	
	private String address;
	
	private String remark;
	
	private BankModel parentBank;
	
	public String getCode(){
		return get(BankModel.CODE);
	}
	
	public void setCode(String code){
		set(BankModel.CODE,code);
	}
	
	public String getName(){
		return get(BankModel.NAME);
	}
	
	public void setName(String name){
		set(BankModel.NAME,name);
	}
	
	public String getShortName(){
		return get(BankModel.SHORT_NAME);
	}
	
	public void setShortName(String shortName){
		set(BankModel.SHORT_NAME,shortName);
	}
	
	public Long getRegionId() {
		if(this.regionId==null){
			return getRefModelId(BankModel.REGION);
		}
		return regionId;
	}

	public void setRegionId(Long regionId) {
		this.regionId = regionId;
	}

	public String getAddress(){
		return get(BankModel.ADDRESS);
	}
	
	public void setAddress(String address){
		set(BankModel.ADDRESS,address);
	}
	
	public String getRemark(){
		return get(BankModel.REMARK);
	}
	
	public void setRemark(String remark){
		set(BankModel.REMARK,remark);
	}

	public BankModel getParentBank() {
		return get(BankModel.PARENT_BANK);
	}

	public void setParentBank(BankModel parentBank) {
		set(BankModel.PARENT_BANK,parentBank);
		if(parentBank!=null){
			setParentId(parentBank.getId());
			parentBank.setHasChildren(true);
		}
	}
	
	public RegionModel getRegionModel() {
		return get(BankModel.REGION);
	}

	public void setRegionModel(RegionModel regionModel) {
		set(BankModel.REGION,regionModel);
		if(regionModel!=null){
			setRegionId(regionModel.getId());
		}
	}

	public String toString(){
		return getName();
	}

	public String[] getModelFields() {
		return BankModel.fieldNames;
	}

	@Override
	public String getParentFiledName() {
		return BankModel.PARENT_BANK;
	}
}
